package tech.wetech.admin3.sys.service;

import org.springframework.stereotype.Service;
import tech.wetech.admin3.sys.repository.AooAnotherMeRepository;
import tech.wetech.admin3.sys.repository.AooAnotherSomeoneRepository;
import tech.wetech.admin3.sys.repository.AooVirtualManRepository;

import java.util.ArrayList;
import java.util.List;

@Service
public class AooQueryService {
  private AooAnotherMeRepository anotherMeRepository;
  private AooAnotherSomeoneRepository anotherSomeoneRepository;
  private AooVirtualManRepository virtualManRepository;
  public AooQueryService(
    AooAnotherMeRepository anotherMeRepository,
    AooAnotherSomeoneRepository anotherSomeoneRepository,
    AooVirtualManRepository virtualManRepository
  ){
    this.anotherMeRepository=anotherMeRepository;
    this.anotherSomeoneRepository=anotherSomeoneRepository;
    this.virtualManRepository=virtualManRepository;
  }

  public List<Object> getDataByEmail(String email){
    List<Object> dataList = new ArrayList<>();
    dataList.addAll(anotherMeRepository.findByEmail(email));
    dataList.addAll(anotherSomeoneRepository.findByEmail(email));
    dataList.addAll(virtualManRepository.findByEmail(email));
    return dataList;
  }

  public List<Object> getDataByEmailAndDigitalName(String email, String digitalName){
    List<Object> dataList = new ArrayList<>();
    dataList.addAll(anotherMeRepository.findByEmailAndDigitalName(email, digitalName));
    dataList.addAll(anotherSomeoneRepository.findByEmailAndDigitalName(email, digitalName));
    dataList.addAll(virtualManRepository.findByEmailAndDigitalName(email, digitalName));
    return dataList;
  }

}
